#include "onewayfunction.h"

OneWayFunction::OneWayFunction()
{

}

QByteArray OneWayFunction::ecFunc(BN_ULONG r, MyBIGNUM &x, MyECPoint &point, EC_GROUP *group)
{
    BIGNUM *tem=BN_new();
    EC_GROUP_get_order(group,tem,nullptr);
    MyBIGNUM order{tem};
    MyBIGNUM y=x.addMod(r,order);
    auto t=point*y;
    size_t len=0;
    auto ret=t.toBuf(len);
    return QByteArray{(char*)ret.get(),static_cast<qsizetype>(len)};
}

QByteArray OneWayFunction::ecFunc(unsigned long long r, MyBIGNUM &&x, MyECPoint &point, EC_GROUP *group)
{
    BIGNUM *tem=BN_new();
    EC_GROUP_get_order(group,tem,nullptr);
    MyBIGNUM order{tem};
    MyBIGNUM y=x.addMod(r,order);
    auto t=point*y;
    size_t len=0;
    auto ret=t.toBuf(len);
    return QByteArray{(char*)ret.get(),static_cast<qsizetype>(len)};
}
